package com.data.collect;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

import com.data.collect.android.receiver.PSdkReceiver;
import com.data.collect.configer.Constance;

/**
 * Created by wanggenlin on 17-6-8.
 */
public class DataInterface {
    Context context;
    private static DataInterface instance;

    public static DataInterface getInstance() {
        if (instance==null){
            instance = new DataInterface();
        }
        return instance;
    }

    public void initSdk(Context context){
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_BATTERY_CHANGED);
        filter.addAction(Intent.ACTION_BATTERY_LOW);
        filter.addAction(Intent.ACTION_BATTERY_OKAY);
        filter.addAction(Intent.ACTION_POWER_CONNECTED);
        filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
        //--锁屏action
        filter.addAction(Intent.ACTION_SCREEN_ON);
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_USER_PRESENT);
        //--系统数据变化
        filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
        filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
        filter.addAction(Intent.ACTION_LOCALE_CHANGED);
        filter.addAction(Intent.ACTION_GTALK_SERVICE_CONNECTED);
        filter.addAction(Intent.ACTION_GTALK_SERVICE_DISCONNECTED);
        filter.addAction(Intent.ACTION_INPUT_METHOD_CHANGED);
        filter.addAction(Intent.ACTION_INPUT_METHOD_CHANGED);
        filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
        filter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
        filter.addAction(Intent.ACTION_WALLPAPER_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_ADDED);
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addDataScheme("package");
        context.registerReceiver(new PSdkReceiver(), filter);
        context.startService(new Intent(Constance.ServiceAction));

    }
}
